package com.nf.handler;

import com.nf.MiniBasicRowProcessor;
import com.nf.MiniResultHandler;
import com.nf.MiniRowProcessor;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MiniArrayHandler implements MiniResultHandler<Object[]> {
    //默认值
    private MiniRowProcessor convert=null;



    public MiniArrayHandler() {
        //采用默认值
        this(Constants.DEFAULT_ROW_PROCESSOR);
    }

    public MiniArrayHandler(MiniRowProcessor convert) {
        this.convert = convert;
    }

    @Override
    public Object[] handle(ResultSet rs) throws SQLException {
        return rs.next()?this.convert.toArray(rs):Constants.EMPTY_ARRAY;
    }
}
